import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

//创建一个路由器
export default new VueRouter({
  routes:[
    {
      path:'/about',
      component:() => import('../views/About.vue')
    },
    {
      path:'/home',
      component:Home,
      //通过children配置子路由
      children:[
        {
          path:'/',
          component:() => import('../components/news.vue')
        },
        {
          path:'/news',//此处不要写/news,vue-router会自动给你加上/
          component:() => import('../components/news.vue'),
          children:[
            {
              path:'/detail/:id/:title',
              component:() => import('../components/detail.vue')
            }
          ]
        },
        {
          path:'/message',
          component:() => import('../components/message.vue')
        }
      ]
    }
  ]
})
